import { request } from '@pkg/request/src';

export enum Api {
  page = '/userGoods/page',
  get = '/userGoods/get',
  update = '/userGoods/update',
  remove = '/userGoods/remove',
  singleUseCheck = '/userGoods/singleUseCheck',
}

enum PayWayApi {
  list = '/payway/list',
}

export const userGoodsPage = (params) =>
  request.get(
    { url: Api.page, params: params },
    {
      errorMessageMode: 'none',
      successMessageMode: 'none',
    },
  );

export const get = (params) =>
  request.get(
    {
      url: Api.get,
      params: params,
    },
    { errorMessageMode: 'none', successMessageMode: 'none' },
  );

export const update = (params) =>
  request.post(
    {
      url: Api.update,
      params: params,
    },
    { errorMessageMode: 'none' },
  );

export const remove = (ids: string) =>
  request.post(
    {
      url: Api.remove,
      params: { ids: ids },
    },
    { errorMessageMode: 'message' },
  );

export const payWayList = (ids: string) =>
  request.get(
    {
      url: PayWayApi.list,
      params: { ids: ids },
    },
    { errorMessageMode: 'none' },
  );

export const singleUseCheck = (params) =>
  request.post(
    {
      url: Api.singleUseCheck,
      params: params,
    },
    { errorMessageMode: 'message', successMessageMode: 'success' },
  );
